package com.jingjiu.homeservicesbiz.controller;

import java.util.List;

import com.jingjiu.homeservicesapi.domain.HouseService;
import com.jingjiu.homeservicesbiz.service.IHouseServiceService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 家政服务：记录各种家政服务的基本信息Controller
 * 
 * @author ruoyi
 * @date 2025-04-16
 */
@Controller
@RequestMapping("/system/service")
public class HouseServiceController extends BaseController
{

    @Autowired
    private IHouseServiceService houseServiceService;



    /**
     * 查询家政服务：记录各种家政服务的基本信息列表
     */
    @RequiresPermissions("system:service:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(HouseService houseService)
    {
        startPage();
        List<HouseService> list = houseServiceService.selectHouseServiceList(houseService);
        return getDataTable(list);
    }

    /**
     * 导出家政服务：记录各种家政服务的基本信息列表
     */
    @RequiresPermissions("system:service:export")
    @Log(title = "家政服务：记录各种家政服务的基本信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(@RequestBody HouseService houseService)
    {
        List<HouseService> list = houseServiceService.selectHouseServiceList(houseService);
        ExcelUtil<HouseService> util = new ExcelUtil<HouseService>(HouseService.class);
        return util.exportExcel(list, "家政服务：记录各种家政服务的基本信息数据");
    }



    /**
     * 新增保存家政服务：记录各种家政服务的基本信息
     */
    @RequiresPermissions("system:service:add")
    @Log(title = "家政服务：记录各种家政服务的基本信息", businessType = BusinessType.INSERT)
    @PostMapping("/update")
    @ResponseBody
    public AjaxResult addSave(@RequestBody HouseService houseService)
    {
        return toAjax(houseServiceService.insertHouseService(houseService));
    }

    /**
     * 修改家政服务：记录各种家政服务的基本信息
     */
    @RequiresPermissions("system:service:edit")
    @GetMapping("/get/{id}")
    public HouseService getById(@PathVariable("id") Long id)
    {
        HouseService houseService = houseServiceService.selectHouseServiceById(id);

        return houseService;
    }

    /**
     * 修改保存家政服务：记录各种家政服务的基本信息
     */
    @RequiresPermissions("system:service:edit")
    @Log(title = "家政服务：记录各种家政服务的基本信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(@RequestBody HouseService houseService)
    {
        return toAjax(houseServiceService.updateHouseService(houseService));
    }

    /**
     * 删除家政服务：记录各种家政服务的基本信息
     */
    @RequiresPermissions("system:service:remove")
    @Log(title = "家政服务：记录各种家政服务的基本信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(houseServiceService.deleteHouseServiceByIds(ids));
    }
}
